home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscTableScroll / MiscRadioTracker.M < prev    next >
Encoding:
Text File  |  1996-02-11  |  3.1 KB  |  96 lines

  1. //=============================================================================
  2. //
  3. //        Copyright (C) 1995 by Paul S. McCarthy and Eric Sunshine.
  4. //                Written by Paul S. McCarthy and Eric Sunshine.
  5. //                            All Rights Reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //        This object is included in the MiscKit by permission from the authors
  10. //        and its use is governed by the MiscKit license, found in the file
  11. //        "License.rtf" in the MiscKit distribution.    Please refer to that file
  12. //        for a list of all applicable permissions and restrictions.
  13. //        
  14. //=============================================================================
  15. //-----------------------------------------------------------------------------
  16. // MiscRadioTracker.M
  17. //
  18. //        Radio-mode selection tracking.
  19. //
  20. //-----------------------------------------------------------------------------
  21. //-----------------------------------------------------------------------------
  22. // $Id: MiscRadioTracker.M,v 1.1 95/09/27 12:21:21 zarnuk Exp $
  23. // $Log:        MiscRadioTracker.M,v $
  24. //    Revision 1.1  95/09/27    12:21:21  zarnuk
  25. //    Initial revision
  26. //    
  27. //-----------------------------------------------------------------------------
  28. #import "MiscRadioTracker.h"
  29. #import "MiscSparseSet.h"
  30. #import "MiscTableBorder.h"
  31.  
  32.  
  33. @implementation MiscRadioTracker
  34.  
  35. //-----------------------------------------------------------------------------
  36. // selectPos:
  37. //-----------------------------------------------------------------------------
  38. - (void) selectPos: (MiscCoord_V)pos
  39.     {
  40.     set->empty();
  41.     set->add( pos );
  42.     set->setCursor( pos );
  43.     }
  44.  
  45.  
  46. //-----------------------------------------------------------------------------
  47. // mouseDown:atPos:
  48. //-----------------------------------------------------------------------------
  49. - (void) mouseDown: (NXEvent const*) event atPos: (MiscCoord_V) pos
  50.     {
  51.     [self selectPos: pos];
  52.     }
  53.  
  54.  
  55. //-----------------------------------------------------------------------------
  56. // mouseDragged:atPos:
  57. //-----------------------------------------------------------------------------
  58. - (void) mouseDragged: (NXEvent const*) event atPos: (MiscCoord_V) pos
  59.     {
  60.     if (!set->isEmpty())
  61.         set->empty();
  62.     if (pos >= 0 && pos < border->count())
  63.         {
  64.         set->add( pos );
  65.         set->setCursor( pos );
  66.         }
  67.     }
  68.  
  69.  
  70. //-----------------------------------------------------------------------------
  71. // mouseUp:atPos:
  72. //
  73. //        NOTE: We emulate Matrix behavior here.    In radio mode if the mouse goes
  74. //                up and the shift key is held down then the cell is deselected.
  75. //-----------------------------------------------------------------------------
  76. - (void) mouseUp: (NXEvent const*) event atPos: (MiscCoord_V) pos
  77.     {
  78.     if (event->flags & NX_SHIFTMASK)
  79.         if (pos >= 0 && pos < border->count() && set->contains( pos ))
  80.             set->empty();
  81.     }
  82.  
  83.  
  84. //-----------------------------------------------------------------------------
  85. // keyDown:atPos:
  86. //-----------------------------------------------------------------------------
  87. - (void) keyDown: (NXEvent const*) event atPos: (MiscCoord_V) pos
  88.     {
  89.     if (!set->isEmpty() && pos == set->getCursor())
  90.         set->empty();
  91.     else
  92.         [self selectPos: pos];
  93.     }
  94.  
  95. @end
  96.